package chapter27;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;
import java.time.temporal.ChronoUnit;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/28 21:18
 */
public class PeriodTest {
    public static void main(String[] args) {
        LocalDate date1 = LocalDate.of(1997, 7, 1);
        LocalDate date2 = LocalDate.now();
        Period period = Period.between(date1, date2);
        System.out.println(period.getYears() + "-" + period.getMonths() + "-" + period.getDays());

        long minutes = Duration.between(LocalTime.of(9, 0), LocalTime.now()).toMinutes();
        System.out.println(minutes);

        long days = ChronoUnit.DAYS.between(date1, date2);
        System.out.println(days);
    }

}
